# -*- coding: utf-8 -*-
from Page.noscanningPage import noscanningPage
from publicModule.switchclass import switchclass
import time
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.webdriver import ActionChains
class noscanning():
    def __init__(self,driver):
        self.driver = driver
        self.noscanningPage = noscanningPage(self.driver)
        self.switchclass = switchclass(self.driver)
    def noscanning(self):
        print('noscanning')
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame("head")
        time.sleep(2)
        self.noscanningPage.groupBtn().click()
    def noscanning1(self):
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame("fraMenu")
        time.sleep(2)
        self.noscanningPage.new().click()
    def nosanning2(self):
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame("fraMenu")
        time.sleep(2)
        self.noscanningPage.noscanningenter().click()
    def noscanning3(self,policyNo,InsuPeriod,PolicyAppDate,EscanCom,SubType,insurancepolicytype):
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame("fraInterface")
        time.sleep(2)
        ActionChains(self.driver).double_click(self.noscanningPage.institutions()).perform()
        time.sleep(1)
        Select(self.noscanningPage.codeselect()).select_by_visible_text(EscanCom)
        time.sleep(1)
        # self.noscanningPage.institutions3().send_keys(companyName)
        # time.sleep(1)
        ActionChains(self.driver).double_click(self.noscanningPage.business()).perform()
        time.sleep(1)
        Select(self.noscanningPage.codeselect()).select_by_visible_text(SubType)
        time.sleep(1)
        self.noscanningPage.policy_num().send_keys(policyNo)
        time.sleep(1)
        ActionChains(self.driver).double_click(self.noscanningPage.policy_style()).perform()
        time.sleep(1)
        Select(self.noscanningPage.codeselect()).select_by_visible_text(insurancepolicytype)
        time.sleep(1)
        self.noscanningPage.cssButton().click()
        time.sleep(1)
        # switchclass.switch()
        windows = self.driver.window_handles
        self.driver.switch_to.window(windows[-1])
        self.noscanningPage.butSubmit().click()
        time.sleep(1)
        windows_1 = self.driver.window_handles
        self.driver.switch_to.window(windows_1[-1])
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame("fraInterface")
        time.sleep(2)
        self.noscanningPage.radioChoose().click()
        time.sleep(1)
        self.noscanningPage.butEnter().click()
        time.sleep(1)
        ActionChains(self.driver).double_click(self.noscanningPage.inpPeriod()).perform()
        time.sleep(1)
        Select(self.noscanningPage.codeselect()).select_by_visible_text(u"Y-年")
        time.sleep(1)
        self.noscanningPage.inpPeriod1().clear()
        time.sleep(1)
        self.noscanningPage.inpPeriod1().send_keys(InsuPeriod)
        time.sleep(1)
        self.noscanningPage.inpPolicyAppDate().clear()
        time.sleep(1)
        self.noscanningPage.inpPolicyAppDate().send_keys(PolicyAppDate)
        time.sleep(1)
        self.noscanningPage.inpPolicyAppDate().click()
        time.sleep(1)
        self.noscanningPage.laydatOk().click()
        time.sleep(1)
        # self.noscanningPage.inpPolicyAppDate().send_keys(Keys.ENTER)
        # time.sleep(1)
        ActionChains(self.driver).double_click(self.noscanningPage.secValDateType()).perform()
        time.sleep(1)
        Select(self.noscanningPage.codeselect()).select_by_visible_text(u"0-保费到账次日")
        time.sleep(1)
        self.noscanningPage.butSave().click()
        time.sleep(1)
        windows = self.driver.window_handles
        self.driver.switch_to.window(windows[-1])
        self.noscanningPage.butSubmit().click()
        time.sleep(1)
        windows_1 = self.driver.window_handles
        self.driver.switch_to.window(windows_1[-1])
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame("fraInterface")
        time.sleep(2)






